From d5c8a7357b67d715cbe247401d48b82057de0705 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Sat, 29 Oct 2016 20:26:10 +0200 Subject: [PATCH] Add LinkBatch to Special:UnwatchedPages Get all the information for blue links in one query. Change-Id: I18cbaf69c5f75e00e48e27d4b5e7220f51c31808 --- includes/specials/SpecialUnwatchedpages.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/includes/specials/SpecialUnwatchedpages.php b/includes/specials/SpecialUnwatchedpages.php index df57744b3a..0cbf00d528 100644 --- a/includes/specials/SpecialUnwatchedpages.php +++ b/includes/specials/SpecialUnwatchedpages.php @@ -43,6 +43,26 @@ class UnwatchedpagesPage extends QueryPage { return false; } + /** + * Pre-cache page existence to speed up link generation + * + * @param IDatabase $db + * @param ResultWrapper $res + */ + public function preprocessResults( $db, $res ) { + if ( !$res->numRows() ) { + return; + } + + $batch = new LinkBatch(); + foreach ( $res as $row ) { + $batch->add( $row->namespace, $row->title ); + } + $batch->execute(); + + $res->seek( 0 ); + } + public function getQueryInfo() { return [ 'tables' => [ 'page', 'watchlist' ], -- 2.20.1